//
//  DengerousFrame.m
//  掌上宏力
//
//  Created by admin on 2017/6/7.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "DengerousFrame.h"
#import "DengerousModel.h"

static CGFloat lab_H = 30;
static CGFloat lab_W = 80;
static CGFloat lef_dis = 5;

@implementation DengerousFrame

-(void)setDengerous:(DengerousModel *)dengerous{
    _dengerous = dengerous;
    CGFloat text_W = kScreenW-lab_W-20-lef_dis;
    //姓名
    _nameF = CGRectMake(lef_dis, 5, lab_W, lab_H);
    _nameLabF = CGRectMake(CGRectGetMaxX(_nameF), 5, text_W, lab_H);
    //来源
    _fromF = CGRectMake(lef_dis, CGRectGetMaxY(_nameF), lab_W, lab_H);
    _fromLabF = CGRectMake(CGRectGetMaxX(_fromF), CGRectGetMaxY(_nameLabF), text_W, lab_H);
    //发布人
    _issueF = CGRectMake(lef_dis, CGRectGetMaxY(_fromF), lab_W, lab_H);
    _issueLabF = CGRectMake(CGRectGetMaxX(_issueF), CGRectGetMaxY(_fromLabF), text_W, lab_H);
    //发布内容
    CGFloat issueContent_H = [self heightWithText:dengerous.issueContent font:15];
    issueContent_H = issueContent_H < lab_H ? lab_H:issueContent_H+10;
    _issueContentF = CGRectMake(lef_dis, CGRectGetMaxY(_issueF), lab_W, lab_H);
    _issueContentLabF = CGRectMake(CGRectGetMaxX(_issueContentF), CGRectGetMaxY(_issueLabF), text_W, issueContent_H);
    //处理医生
    _doctorF = CGRectMake(lef_dis, CGRectGetMaxY(_issueContentLabF), lab_W, lab_H);
    _doctorLabF = CGRectMake(CGRectGetMaxX(_doctorF), CGRectGetMaxY(_issueContentLabF), text_W, lab_H);
    
    _cellHeight = CGRectGetMaxY(_doctorLabF)+5;
}

-(CGFloat)heightWithText:(NSString *)text font:(CGFloat)font{
    CGFloat text_W = kScreenW-LeftDis*2-lab_W-20;
    return [Factory sizeWithText:text font:[UIFont systemFontOfSize:font] maxSize:CGSizeMake(text_W, CGFLOAT_MAX)].height;
}

@end
